<?php
class Macys_Api_V2_User extends Macys_Api_V2_Abstract {

	protected $username;
	protected $password;

	protected $getParams = array();

	protected function init() {
		$this->keyName = "v2user";
		$this->endPoint = "/v2/user";
		$this->method = "GET";


	}


	public function getShowParams() {
		$show = array('show' => array('summary' => 'Summary', 'shipping'=>'Shipping'));
	}



	public function getDetails() {
		$this->run();
	}

	protected function processAdditionalInputParams($params) {
		if(isset($params['show'])) {
			$showparams = implode(',', $params['show']);
			$this->getParams = array ('show' => $showparams);
			unset($params['show']);
		}
	}


	protected function setGetParams() {
		if(isset($this->getParams)) {
			foreach ($this->getParams as $k=>$v) {
				$this->_client->setParameterGet($k, $v);
			}
		}
	}

	/**
	 * For Protected Services we need some special processing for API Keys and user Accesstoken etc
	 * @see Macys_Api_V2_Abstract::setConfig()
	 */
	protected function setConfig($conf=null) {
		$conf = $this->conf->getOAuthDetails();
		if($this->conf->getManualUserContext()) {
			$this->_client->setUserContextHeader($this->conf->getManualUserContext());
			$config['api_uri'] = $conf['auth_uri'];
		}
		else {
			$config['api_uri'] = $conf['mashery_uri'];
			if(Zend_Auth::getInstance()->hasIdentity()) {
				$this->_client->setUserAccessHeader(Zend_Auth::getInstance()->getIdentity());
				$config[Macys_Constants::MACYS_CLIENT_HEADER] = $conf['client_id'];
			}
			else {
				throw new Macys_Api_V2_Exception('User Access token / User context is not set');
			}
		}
		parent::setConfig($config);
	}


}